



//
//  LJHAlbumsDetailCell.m
//  HEARME
//
//  Created by liujinhui on 16/1/27.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "LJHAlbumsDetailCell.h"

@implementation LJHAlbumsDetailCell




- (void)dealloc
{
    [_iconImageV release];
    [_iconLikeV release];
    [_trackDigest release];
    [_trackPic release];
    [_trackTitle release];
    [_playButton release];
    [_playCount release];
    [_duration release];
    [_Comments release];
    [super dealloc];
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createCell];
    }
    
    return self;
}

-(void)createCell
{
    self.trackPic = [[UIImageView alloc] initWithFrame:CGRectMake(self.contentView.bounds.origin.x + 15, self.contentView.bounds.origin.y + 10, 50, 50) ];
    self.trackPic.backgroundColor = [UIColor whiteColor];
    self.trackPic.layer.masksToBounds = YES;
    self.trackPic.layer.cornerRadius = 25;
    [self.contentView addSubview:self.trackPic];
    [_trackPic release];
    
    self.playButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.playButton.frame = CGRectMake(self.contentView.bounds.origin.x + 15, self.contentView.bounds.origin.y + 10, 20, 20);
    self.playButton.backgroundColor = [UIColor clearColor];
    self.playButton.alpha = 0.5;
    self.playButton.center = self.trackPic.center;
    [self.playButton setImage:[UIImage imageNamed:@"cell_sound_play_n@2x.png"] forState:UIControlStateNormal];
    [self.contentView addSubview:self.playButton];
    
    
    
    self.trackTitle = [[LJHBaseLable alloc] initWithFrame:CGRectMake(self.trackPic.frame.origin.x + self.trackPic.frame.size.width + 10, self.contentView.bounds.origin.y + 10, WIDTH * 0.6, 40)];
    self.trackTitle.font = [UIFont systemFontOfSize:13 weight:0];
    self.trackTitle.numberOfLines = 2;
    [self.contentView addSubview:self.trackTitle];
    [_trackTitle release];
    
    self.trackDigest = [[LJHBaseLable alloc] initWithFrame:CGRectMake(self.trackPic.frame.origin.x + self.trackPic.frame.size.width + 10 ,self.trackTitle.frame.origin.y + self.trackTitle.frame.size.height + 5, WIDTH * 0.6, 10)];
    self.trackDigest.backgroundColor = [UIColor clearColor];
    self.trackDigest.font = [UIFont systemFontOfSize:11 weight:0];
    [self.contentView addSubview:self.trackDigest];
//    self.trackDigest.textColor = [UIColor lightGrayColor];
    [_trackDigest release];
    
    self.iconImageV = [[UIImageView alloc] initWithFrame:CGRectMake(self.trackPic.frame.origin.x + self.trackPic.frame.size.width+5 , self.trackDigest.frame.origin.y + self.trackDigest.frame.size.height+5, HEIGHT*0.01, HEIGHT*0.01)];
    self.iconImageV.backgroundColor = [UIColor clearColor];
    self.iconImageV.image = [UIImage imageNamed:@"album_playCountLogo@2x.png"];
    [self.contentView addSubview:self.iconImageV];
    [self.iconImageV release];
    
    self.playCount = [[LJHBaseLable alloc] initWithFrame:CGRectMake(self.iconImageV.frame.origin.x+self.iconImageV.frame.size.width + HEIGHT*0.01 , self.trackDigest.frame.origin.y + self.trackDigest.frame.size.height + 2, 50, 10)];
    self.playCount.backgroundColor = [UIColor clearColor];
    self.playCount.font = [UIFont systemFontOfSize:11 weight:0];
    [self.contentView addSubview:self.playCount];
    self.playCount.textAlignment = NSTextAlignmentRight;
//    self.playCount.textColor = [UIColor lightGrayColor];
    [_playCount release];
    
    self.iconLikeV = [[UIImageView alloc] initWithFrame:CGRectMake(self.trackPic.frame.origin.x + self.trackPic.frame.size.width+5 , self.trackDigest.frame.origin.y + self.trackDigest.frame.size.height+5, HEIGHT*0.01, HEIGHT*0.01)];
    self.iconLikeV.backgroundColor = [UIColor clearColor];
    self.iconLikeV.image = [UIImage imageNamed:@"find_emotion@2x.png"];
    [self.contentView addSubview:self.iconLikeV];
    [self.iconLikeV release];
    
    //时长
    self.duration = [[LJHBaseLable alloc] initWithFrame:CGRectMake(self.playCount.frame.origin.x + self.playCount.frame.size.width + 50 , self.playCount.frame.origin.y , 50, 10)];
    self.duration.backgroundColor = [UIColor clearColor];
    self.duration.font = [UIFont systemFontOfSize:11 weight:0];
    [self.contentView addSubview:self.duration];
    self.duration.textAlignment = NSTextAlignmentRight;
//    self.duration.textColor = [UIColor lightGrayColor];
    [_duration release];
    
    
}


-(void)setTrackModel:(LJHTrackModel *)trackModel
{
    if (_trackModel != trackModel) {
        [_trackModel release];
        _trackModel = [trackModel retain];
    }
    
    NSURL *url = [NSURL URLWithString:_trackModel.coverSmall];
    [self.trackPic sd_setImageWithURL:url placeholderImage:PLACEHOLDER];
    self.trackTitle.text = _trackModel.title;
    [self.trackTitle sizeToFit];
    self.trackDigest.frame = CGRectMake(self.trackPic.frame.origin.x + self.trackPic.frame.size.width + 10, self.trackTitle.frame.origin.y + self.trackTitle.frame.size.height + 5, 200, 10);
    self.trackDigest.text = [NSString stringWithFormat:@"by %@", _trackModel.nickname];
    self.iconImageV.frame = CGRectMake(self.trackPic.frame.origin.x + self.trackPic.frame.size.width+10, self.trackDigest.frame.origin.y + self.trackDigest.frame.size.height+10, HEIGHT*0.016, HEIGHT*0.016);
    self.playCount.frame = CGRectMake(self.trackPic.frame.origin.x + self.trackPic.frame.size.width + 10 , self.trackDigest.frame.origin.y + self.trackDigest.frame.size.height + 10, 50, 10);
    self.playCount.text = [NSString stringWithFormat:@"%.2f万", (CGFloat)_trackModel.playtimes/10000];
    self.iconLikeV.frame = CGRectMake(self.playCount.frame.origin.x + self.playCount.frame.size.width+10, self.trackDigest.frame.origin.y + self.trackDigest.frame.size.height + 10, HEIGHT*0.02, HEIGHT*0.02);
    self.duration.frame = CGRectMake(self.iconLikeV.frame.origin.x + self.iconLikeV.frame.size.width + 10 , self.playCount.frame.origin.y , 50, 10);
    self.duration.text = [NSString stringWithFormat:@"%ld人想听", _trackModel.likes];
    [self.duration sizeToFit];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
